#ifndef __TASK_HPP__
#define __TASK_HPP__

enum {
    EXITCODE = -1,
    DIVERR,
    MODERR
};

class task
{
public:
    task(int _x, int _y, char _oper, int exitcode = EXITCODE)
        :x(_x)
        , y(_y)
        , oper(_oper)
    {}

    void run()
    {
        switch (oper)
        {
        case '+':
            result = x + y;
            break;
        case '-':
            result = x - y;
            break;
        case '*':
            result = x * y;
            break;
        case '/':
            if(x == 0 && y == 0)
            {
                exitcode = DIVERR;
            }
            result = x / y;
            break;
        case '%':
            if(x == 0 && y == 0)
            {
                exitcode = MODERR;
            }
            result = x % y;
            break;
        default:
            std::cout << "calculation error" << std::endl;
            break;
        }
    }

    void operator()()
    {
        run();
        // GetRet();
    }

    void GetRet()
    {
        std::cout << x << oper << y << "=" << result << " exitcode: " << exitcode << std::endl;
    }
private:
    int x;
    int y;
    char oper;

    int result;
    int exitcode;
};

#endif
